//
//  Ext+UIImageView.swift
//  weibo_zha
//
//  Created by _zha on 16/10/24.
//  Copyright © 2016年 渣. All rights reserved.
//

import UIKit
import SDWebImage

extension UIImageView {

    convenience init(imgName: String) {
        self.init(image: UIImage(named:imgName))
    }
    
    //SDWebImage的封装
    func ao_setImage(withUrlString: String?, placeholderImgName: String?){
        // 获取图片的 url
        let url = URL(string: withUrlString ?? "")
        // 判断他是否为 nil
        guard let u = url else {
            return
        }
        // 调用 sdWebImage 的方法
        self.sd_setImage(with: u, placeholderImage: UIImage(named: placeholderImgName ?? ""))
    }
    
}
